package com.digitalchina.trade.controller;

import com.digitalchina.trade.entity.TbAccount;
import com.digitalchina.trade.mapper.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;

@Controller
public class LoginController {
    @Autowired
    private AccountMapper accountMapper;

    @PostMapping("/login")
    public String login(TbAccount tbAccount ,Model model){
        TbAccount tbAccount1 = accountMapper.login(tbAccount);
        if (tbAccount1==null){
            model.addAttribute("msg","账号不存在");
            return "login";
        }else {
            if (tbAccount1.getAccount_pwd().equals(tbAccount.getAccount_pwd())){
                return "result";
            }else {
                model.addAttribute("msg","密码错误");
                return "login";
            }
        }
    }

}
